#!/bin/bash

echo "==请在root模式下运行脚本，按回车继续=="
read cmd

SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
cd $SCRIPT_DIR

cd $SCRIPT_DIR/terminal-surfing/src
tar -xf gfwlist2privoxy.tar.gz
mv gfwlist2privoxy/ssr /usr/local/bin
chmod +x /usr/local/bin/ssr

tar -xf shadowsocksr.tar.gz
mv shadowsocksr /usr/local/share/
rm -rf shadowsocksr

cd libsodium-manually
tar -xf LATEST.tar.gz && cd libsodium-stable
./configure
make
make check
make install 
ldconfig
rm -rf libsodium-stable

apt install privoxy
mv $SCRIPT_DIR/terminal-surfing/src/ssr_manager /usr/local/bin
chmod +x ssr_manager
echo "==finished=="
echo "PAC设置请手动配置"
# cd $SCRIPT_DIR/terminal-surfing/src/gfwlist2privoxy/
# echo "输入127.0.0.1:1080"
# bash gfwlist2privoxy
# cp -af $SCRIPT_DIR/terminal-surfing/src/gfwlist2privoxy/gfw.action /etc/privoxy/
# echo 'actionsfile gfw.action' >> /etc/privoxy/config
# export http_proxy=http://127.0.0.1:8118
# export https_proxy=http://127.0.0.1:8118
# export no_proxy=localhost
# systemctl start privoxy.service

# rm -rf $SCRIPT_DIR/terminal-surfing/src/gfwlist2privoxy